﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GOF23.Singleton
{
    /// <summary>
    /// 完全懒汉式
    /// 通过内嵌类的方式先实现了只有在真正引用Instance时才进行实例化，性能与Singleton4无异
    /// </summary>
    public sealed class Singleton5
    {
        private Singleton5() { }
        public static Singleton5 Instance
        {
            get 
            {
                return Nested.instance;
            }
        }
        private class Nested
        {
            static Nested() { }
            internal static readonly Singleton5 instance = new Singleton5();
        }
    }
}
